package com.h2.tinyspring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.h2.org.springframework.beans.factory.IResourceManager;
import com.h2.util.resource.android.AndroidResourceManager;

import android.app.Activity;
import android.os.Bundle;

public class TinySpringActivity extends Activity {
   
   private static final Logger LOG = LoggerFactory
         .getLogger(TinySpringActivity.class);

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      
      final AndroidResourceManager resManager = new AndroidResourceManager();
      resManager.setAssetManager(getAssets());

      ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
            "test-primary-ctx.xml") {
         @Override
         public IResourceManager getResorceManager() {
            return resManager;
         }
      };
      

      TestService service = ctx.getBean(TestService.class);
      
      LOG.debug(service.getTestDao().getFileName());
      LOG.debug(service.getTestDao().getFileDir());
      LOG.debug(service.getTestDao().getTestInit());
   }
}